home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / hh_str13.zip / DATETEST.C < prev    next >
C/C++ Source or Header  |  1993-03-13  |  5KB  |  133 lines

  1. /*
  2.     In working with various bulletin boards and dealing with
  3.     miscellaneous files over the years, we have found a number of
  4.     date formats in use. To facilitate our own function naming, we
  5.     have given the various types the following totally arbitrary
  6.     numerical designations. This information is contained with both
  7.     the "strdate<n>" and "strdateconv" functions, for ease of
  8.     reference.
  9.  
  10.         type     format
  11.         ----     ------
  12.           1    mm/dd/yy   NOTE: mm and dd will be padded on the
  13.           2    mm-dd-yy     left with a 0 where necessary
  14.           3     m/ d/yy   NOTE: m and d will be padded on the
  15.           4     m- d-yy     left with a blank where necessary
  16.           5    m/d/yy       NOTE: m and d can be one digit or two
  17.           6    m-d-yy         digits but will not be padded
  18.                      with either 0's or blanks
  19.           7     yy/mm/dd   NOTE: this format is a sortable version
  20.                      which is similar to type 1
  21.  
  22.     As can be seen above, the difference between the even and odd
  23.     types is the use of '-' versus '/' as the separator character.
  24.     The difference between types 1/2, 3/4 and 5/6 is as follows:
  25.  
  26.         1/2    Format is totally fixed and there are no blanks.
  27.             0's will be added to the left of mm and dd as
  28.             necessary to fill out the format.
  29.  
  30.         3/4    Exactly the same as 1/2 except that no 0's will
  31.             be added, so the format may contain blanks.
  32.  
  33.         5/6    The date appears in minimal form using a variable
  34.             format with no leading blanks or zeros.
  35.  
  36.           7    This is identical to 1, except that the order of
  37.             the month/day/year has been changed so as to
  38.             provide a "sortable" format.
  39.  
  40.  
  41. */
  42.  
  43. #include <string.h>
  44. #include <stdlib.h>
  45. #include <dos.h>
  46. #include <time.h>
  47. #include <stdio.h>
  48. #include "hhstring.h"
  49.  
  50. /************************************************************************/
  51. /*                                    */
  52. /*    main                                */
  53. /*                                    */
  54. void main(void)
  55. { char date_string[9];
  56.  
  57.   printf("\n");
  58.   printf("%s  ", strdate1(date_string));
  59.   printf("%s  ", strdate2(date_string));
  60.   printf("%s  ", strdate3(date_string));
  61.   printf("%s  ", strdate4(date_string));
  62.   printf("%s  ", strdate5(date_string));
  63.   printf("%s  ", strdate6(date_string));
  64.   printf("%s  ", strdate7(date_string));
  65.   printf("\n\n");
  66.  
  67.   printf("%s  ", strdateconv(strdate1(date_string), 1, 1));
  68.   printf("%s  ", strdateconv(strdate1(date_string), 1, 2));
  69.   printf("%s  ", strdateconv(strdate1(date_string), 1, 3));
  70.   printf("%s  ", strdateconv(strdate1(date_string), 1, 4));
  71.   printf("%s  ", strdateconv(strdate1(date_string), 1, 5));
  72.   printf("%s  ", strdateconv(strdate1(date_string), 1, 6));
  73.   printf("%s  ", strdateconv(strdate1(date_string), 1, 7));
  74.   printf("\n");
  75.  
  76.   printf("%s  ", strdateconv(strdate2(date_string), 2, 1));
  77.   printf("%s  ", strdateconv(strdate2(date_string), 2, 2));
  78.   printf("%s  ", strdateconv(strdate2(date_string), 2, 3));
  79.   printf("%s  ", strdateconv(strdate2(date_string), 2, 4));
  80.   printf("%s  ", strdateconv(strdate2(date_string), 2, 5));
  81.   printf("%s  ", strdateconv(strdate2(date_string), 2, 6));
  82.   printf("%s  ", strdateconv(strdate2(date_string), 2, 7));
  83.   printf("\n");
  84.  
  85.   printf("%s  ", strdateconv(strdate3(date_string), 3, 1));
  86.   printf("%s  ", strdateconv(strdate3(date_string), 3, 2));
  87.   printf("%s  ", strdateconv(strdate3(date_string), 3, 3));
  88.   printf("%s  ", strdateconv(strdate3(date_string), 3, 4));
  89.   printf("%s  ", strdateconv(strdate3(date_string), 3, 5));
  90.   printf("%s  ", strdateconv(strdate3(date_string), 3, 6));
  91.   printf("%s  ", strdateconv(strdate3(date_string), 3, 7));
  92.   printf("\n");
  93.  
  94.   printf("%s  ", strdateconv(strdate4(date_string), 4, 1));
  95.   printf("%s  ", strdateconv(strdate4(date_string), 4, 2));
  96.   printf("%s  ", strdateconv(strdate4(date_string), 4, 3));
  97.   printf("%s  ", strdateconv(strdate4(date_string), 4, 4));
  98.   printf("%s  ", strdateconv(strdate4(date_string), 4, 5));
  99.   printf("%s  ", strdateconv(strdate4(date_string), 4, 6));
  100.   printf("%s  ", strdateconv(strdate4(date_string), 4, 7));
  101.   printf("\n");
  102.  
  103.   printf("%s  ", strdateconv(strdate5(date_string), 5, 1));
  104.   printf("%s  ", strdateconv(strdate5(date_string), 5, 2));
  105.   printf("%s  ", strdateconv(strdate5(date_string), 5, 3));
  106.   printf("%s  ", strdateconv(strdate5(date_string), 5, 4));
  107.   printf("%s  ", strdateconv(strdate5(date_string), 5, 5));
  108.   printf("%s  ", strdateconv(strdate5(date_string), 5, 6));
  109.   printf("%s  ", strdateconv(strdate5(date_string), 5, 7));
  110.   printf("\n");
  111.  
  112.   printf("%s  ", strdateconv(strdate6(date_string), 6, 1));
  113.   printf("%s  ", strdateconv(strdate6(date_string), 6, 2));
  114.   printf("%s  ", strdateconv(strdate6(date_string), 6, 3));
  115.   printf("%s  ", strdateconv(strdate6(date_string), 6, 4));
  116.   printf("%s  ", strdateconv(strdate6(date_string), 6, 5));
  117.   printf("%s  ", strdateconv(strdate6(date_string), 6, 6));
  118.   printf("%s  ", strdateconv(strdate6(date_string), 6, 7));
  119.   printf("\n");
  120.  
  121.   printf("%s  ", strdateconv(strdate7(date_string), 7, 1));
  122.   printf("%s  ", strdateconv(strdate7(date_string), 7, 2));
  123.   printf("%s  ", strdateconv(strdate7(date_string), 7, 3));
  124.   printf("%s  ", strdateconv(strdate7(date_string), 7, 4));
  125.   printf("%s  ", strdateconv(strdate7(date_string), 7, 5));
  126.   printf("%s  ", strdateconv(strdate7(date_string), 7, 6));
  127.   printf("%s  ", strdateconv(strdate7(date_string), 7, 7));
  128.   printf("\n");
  129.  
  130. }                    /* end function datedemo    */
  131.  
  132.  
  133.